
<!DOCTYPE html>
<!--[if IEMobile 7 ]><html class="no-js iem7"><![endif]-->
<!--[if lt IE 9]><html class="no-js lte-ie8"><![endif]-->
<!--[if (gt IE 8)|(gt IEMobile 7)|!(IEMobile)|!(IE)]><!--><html class="no-js"><!--<![endif]-->
<head>
  <meta charset="utf-8">
  <title>
    
  一篇文章搞定 Centos7 安装与配置JDK8 - LZH-DEV-TECH-SHARE
  

  </title>
  <meta name="author" content="">
  <meta name="description" content="">

  <meta name="HandheldFriendly" content="True">
  <meta name="MobileOptimized" content="320">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  
  <link href="asset/css/screen.css" media="screen, projection" rel="stylesheet" type="text/css">
  <link href="atom.xml" rel="alternate" title="LZH-DEV-TECH-SHARE" type="application/atom+xml">
  <script src="asset/js/modernizr-2.0.js"></script>
  <script src="asset/js/jquery.min.js"></script>
  <script src="asset/highlightjs/highlight.pack.js"></script>
  <link href="asset/highlightjs/styles/solarized_light.css" media="screen, projection" rel="stylesheet" type="text/css">
  <script>hljs.initHighlightingOnLoad();</script>

  <style type="text/css">
  .cat-children-p{ padding: 6px 0px;}
  .hljs{background: none;}
  </style>
  <script type="text/javascript">
  var isAddSildbar = true;
  </script>
  <script src="asset/js/octopress.js" type="text/javascript"></script>
</head>
<script type="text/javascript">
//链接新开窗口
function addBlankTargetForLinks () {
  $('a[href^="http"]').each(function(){
      $(this).attr('target', '_blank');
  });
}
$(document).ready(function(event) {
  addBlankTargetForLinks();
});
</script>
<body   >
  <header role="banner"><hgroup>
  <h1><a href="index.html">LZH-DEV-TECH-SHARE</a></h1>
  
    <h2></h2>
  
</hgroup>

</header>
  <nav role="navigation"><ul class="subscription" data-subscription="rss">
  <li><a href="atom.xml" rel="subscribe-rss" title="subscribe via RSS">RSS</a></li>
  
</ul>
  
<form action="http://google.com/search" method="get">
  <fieldset role="search">
    <input type="hidden" name="q" value="site:" />
    <input class="search" type="text" name="q" results="0" placeholder="Search"/>
  </fieldset>
</form>
  
<ul class="main-navigation">

  <li id=""><a target="self" href="index.html">Home</a></li>

  <li id=""><a target="_self" href="archives.html">Archives</a></li>

</ul>

</nav>
  <div id="main">
    <div id="content"> 
<div>
	<article class="hentry" role="article">
	<header>
			  	<h1 class="entry-title">一篇文章搞定 Centos7 安装与配置JDK8</h1>
				<p class="meta"><time datetime="2018-10-30T11:19:17+08:00" pubdate data-updated="true">2018/10/30</time></p>
			 </header>
		  	<div class="entry-content">
			  	<ul>
<li>
<a href="#toc_0">检查是否安装过JDK</a>
</li>
<li>
<a href="#toc_1">下载安装包并上传</a>
</li>
<li>
<a href="#toc_2">使用rpm的方式安装JDK</a>
</li>
<li>
<a href="#toc_3">安装完成后的检查</a>
</li>
<li>
<a href="#toc_4">配置环境变量</a>
</li>
<li>
<a href="#toc_5">安装结束</a>
</li>
</ul>


<h2 id="toc_0">检查是否安装过JDK</h2>

<pre><code class="language-shell">rpm -qa | grep java
</code></pre>

<h2 id="toc_1">下载安装包并上传</h2>

<p>注意, 这里一定选择在官网下载, 并且选择下载rpm包如图<br/>
<img src="media/15408695578947/15408696761847.jpg" alt="" style="width:562px;"/><br/>
下载好后, 上传到服务器</p>

<h2 id="toc_2">使用rpm的方式安装JDK</h2>

<pre><code class="language-shell">rpm -ivh jdk-8u191-linux-x64.rpm
</code></pre>

<h2 id="toc_3">安装完成后的检查</h2>

<p>通过上一步骤, 我们已经安装好了java, 我们可以使用如下命令检查安装结果</p>

<pre><code class="language-shell">java -version
</code></pre>

<h2 id="toc_4">配置环境变量</h2>

<pre><code class="language-shell">vim /etc/profile

JAVA_HOME=/usr/java/jdk1.8.0_191-amd64
JRE_HOME=/usr/java/jdk1.8.0_191-amd64/jre
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
export JAVA_HOME JRE_HOME PATH CLASSPATH
</code></pre>

<h2 id="toc_5">安装结束</h2>

<p>至此安装结束, 需要注意的是, 在最后你可能需要重启shell, 或者source shell 配置文件来使环境变量配置生效, 具体如下:</p>

<pre><code class="language-shell">source /etc/profile
</code></pre>

			</div>

		
	  
		<footer>
		 <p class="meta">

			<strong>Categories:</strong>&nbsp; 
			<span class="categories">
			
			    <a class='category' href='back-end.html'>back-end</a>&nbsp;
			 
			</span>
		    </p>
		    <p class="meta">
		      
		 </p>
	    
		<div class="sharing">
		  
          

          

		</div>

	    <p class="meta">
	    
	        <a class="basic-alignment left" href="15408703788547.html" 
	        title="Previous Post: 一篇文章搞定 centos7 下安装 nvm和node">&laquo; 一篇文章搞定 centos7 下安装 nvm和node</a>
	    
	    
	        <a class="basic-alignment right" href="15408688513918.html" 
	        title="Next Post: 一篇文章搞定centos7 oh-my-zsh安装">一篇文章搞定centos7 oh-my-zsh安装 &raquo;</a>
	    
	    </p>
	  </footer>
	</article>
</div>
 <aside class="sidebar"> 

	<section>
	  <h1>Categories</h1>
	  <ul id="recent_posts">
	  
	      <li class="post">
	        <a href="version-control.html"><strong>version-control&nbsp;(2)</strong></a>
	        
	        
	        
	      </li>
	  
	      <li class="post">
	        <a href="shell.html"><strong>shell&nbsp;(1)</strong></a>
	        
	        
	        
	      </li>
	  
	      <li class="post">
	        <a href="back-end.html"><strong>back-end&nbsp;(4)</strong></a>
	        
	        
	        
	      </li>
	  
	      <li class="post">
	        <a href="front-end.html"><strong>front-end&nbsp;(5)</strong></a>
	        
	        
	        
	      </li>
	  
	      <li class="post">
	        <a href="version-control-1.html"><strong>version-control&nbsp;(1)</strong></a>
	        
	        
	        
	      </li>
	  
	      <li class="post">
	        <a href="other.html"><strong>other&nbsp;(2)</strong></a>
	        
	        
	        
	      </li>
	   
	  </ul>
	</section>
	<section>
	  <h1>Recent Posts</h1>
	  <ul id="recent_posts">
	  
	      
		      <li class="post">
		        <a href="15413898294420.html">RESTful API 最佳实践</a>
		      </li>
	     
	  
	      
		      <li class="post">
		        <a href="15411425055347.html">LZH-DEV-GROUP Git Workflow 实践详解</a>
		      </li>
	     
	  
	      
		      <li class="post">
		        <a href="15410718240579.html">如何使用PM2进程管理器, 守护java进程</a>
		      </li>
	     
	  
	      
		      <li class="post">
		        <a href="15408811446857.html">一篇文章搞定 centos7 上的 mysql 安装</a>
		      </li>
	     
	  
	      
		      <li class="post">
		        <a href="15408703788547.html">一篇文章搞定 centos7 下安装 nvm和node</a>
		      </li>
	     
	  
	      
	  
	      
	  
	      
	  
	      
	  
	      
	  
	      
	  
	      
	  
	      
	  
	      
	  
	      
	   
	  </ul>
	</section>
	
</aside> </div></div>
  <footer role="contentinfo"><p>
  Copyright &copy; 2014 -  -
  <span class="credit">Powered by <a target="_blank" href="http://www.mweb.im">MWeb</a> &nbsp;&nbsp; Theme by <a href="http://octopress.org">Octopress</a></span>
</p>

</footer>

  
    




</body>
</html>